//---------------------------------------------------------------------------

#ifndef GlassesBridgeH
#define GlassesBridgeH

#include "Sequence.h"

class TGlassesFirm;
class TGlassesModel;

class TGlassesBridge
{
   public:
      TGlassesBridge( TDatabase * database);
      ~TGlassesBridge();

      void GetFirms( TStrings * firms);
      void GetModels( __int64 id, TStrings * models);
      void Add( TGlassesFirm * firm, TStrings * models);
      void Update( TGlassesFirm * firm, TStrings * models);
      void Delete( __int64 id);

      bool GetFirm(AnsiString name, TGlassesFirm* firm);
      bool GetModel(__int64 firmID, AnsiString modelName, TGlassesModel* model);

   private:
      TSequence * sequence;

      TQuery * qryGetFirms;
      TQuery * qryGetModels;
      TQuery * qryAdd;
      TQuery * qryAddModel;
      TQuery * qryDelete;
      TQuery * qryDeleteModel;
      TQuery * qryGetFirmByName;
      TQuery * qryGetModelByName;

      void BuildGetFirmsQuery();
      void BuildGetModelsQuery();
      void BuildAddQuery();
      void BuildDeleteQuery();
      void BuildGetFirmByName();
      void BuildGetModelByName();
};

class TGlassesFirm : public TObject
{
   public:
      __int64 id;
      AnsiString name;
      AnsiString address;
      AnsiString phone;

      TGlassesFirm();
      TGlassesFirm( __int64 id, AnsiString name, AnsiString address, AnsiString phone);
};

class TGlassesModel : public TObject
{
   public:
      __int64 firmID;
      AnsiString name;
      Currency price;
      int bought;
      int sold;

      TGlassesModel();
      TGlassesModel( __int64 firmID, AnsiString name, Currency price, int bought, int sold);
};

#endif
